package com.example.FirstBook.Activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.example.FirstBook.Bean.FoodBean;
import com.example.myapplication.R;

public class Food_Details_Activity extends AppCompatActivity {

    private ImageView titleBackImage;
    private TextView titleText;
    private ImageView titleCamera;
    private ImageView foodDetailsImage;
    private TextView foodDetailsTitle;
    private TextView foodDetailsDetails;
    private TextView foodDetailsNot;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_food__details_);
        initView();
        //接收传过来的数据
        FoodBean foodBean=(FoodBean) getIntent().getSerializableExtra("details");
        //显示到控件上
        titleText.setText(foodBean.getTitle());
        foodDetailsImage.setImageResource(foodBean.getImage());
        foodDetailsTitle.setText(foodBean.getTitle());
        foodDetailsDetails.setText(foodBean.getDetails());
        foodDetailsNot.setText(foodBean.getNomal());
    }
    /*
    初始化控件
     */
    private void initView() {
        titleBackImage = (ImageView) findViewById(R.id.title_back_image);
        titleText = (TextView) findViewById(R.id.title_text);
        titleCamera = (ImageView) findViewById(R.id.title_camera);
        foodDetailsImage = (ImageView) findViewById(R.id.food_details_image);
        foodDetailsTitle = (TextView) findViewById(R.id.food_details_title);
        foodDetailsDetails = (TextView) findViewById(R.id.food_details_details);
        foodDetailsNot = (TextView) findViewById(R.id.food_details_not);
        //销毁当前的活动，返回到上一层
        titleBackImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}
